import VConsole from 'vconsole';

import { createApp } from 'vue';
import router from '@/router';
import store from '@/store';
import App from './App.vue';
import {getDevicePage} from '@/lib/device';
import ui from './ui-factory';
import 'amfe-flexible';
import createContainer from '@/global/app-context';

if (process.env.NODE_ENV === 'development') {
    new VConsole()
}

const view = createContainer('app')(App);
const app = createApp(view);

// 路由检测符合跳转条件则转入对应手机端路由
router.beforeEach((to, from) => {
    if (to.name) {
        getDevicePage({
            routeName: to.name as string,
            queries: to.query,
            params: to.params,
            mobile: 'appmooc',
            web: 'mooc',
            curDevice: 'mobile'
        });
    }
});
ui.register(app).use(router).use(store).mount('#app');